﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OWC11;
using HZ.MBSM.DBUtility;
public partial class Supervise_RepotShowImge : System.Web.UI.Page
{
    int ImgeWith = 414, ImgeHeight = 520;
    protected void Page_Load(object sender, EventArgs e)
    {
        showImage();
    }
    private void showImage()
    {
        string[] arrPrice = new string[50];
        string[] arrValueNames = new string[50];
        string strId = SysFun.IsSQL(Request.QueryString["Goodsid"].ToString());
        string strYear = SysFun.IsSQL(Request.QueryString["Year"].ToString());
        string strArea = SysFun.IsSQL(Request.QueryString["Area"].ToString());
        int ChildNum = strArea.Split(',').Length;
        string strGoodsid = ""; //查询的字段
        

        for (int cod = 0; cod < ChildNum; cod++)
        {
            strGoodsid += "," + strArea.Split(',')[cod].Split('|')[0].ToString();
            arrValueNames[cod] = strArea.Split(',')[cod].Split('|')[1].ToString();
        }
        if (strGoodsid.Length > 0)
        {
            strGoodsid = strGoodsid.Remove(0, 1);
        }
        string strSql = "Select " + strGoodsid + " From AreaPrice where goodsid=" + strId + " and year=" + strYear;
        Db db = new Db();
        DataTable da = db.DataTable(strSql);
        for (int i = 0; i < ChildNum; i++)
        {
            arrPrice[i] = da.Rows[0].ItemArray[i].ToString();
        }
        Class1 dd = new Class1();
        dd.chartTitleValue = "价格统计图";                    // 标题
        dd.chartTypeValue = DropDownList1.SelectedValue; //显示类型
        dd.chartCategoriesArrValue = arrValueNames;                //显示列
        dd.chartValuesArrValue = arrPrice;                    //列值

        OWC11.ChartSpaceClass oChartSpace = dd.BuildCharts();

        string path = Server.MapPath( ""+DropDownList1.SelectedValue +".gif");
        oChartSpace.ExportPicture(path, "gif", 600, 500);
        Image1.Height = ImgeWith;
        Image1.Width = ImgeHeight;
        Image1.ImageUrl = "" + DropDownList1.SelectedValue + ".gif";
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) //比例
    {
        switch (DropDownList2.SelectedValue)
        {
            case "50":
                ImgeWith = (int)(414 * 0.5);
                ImgeHeight = (int)(520 * 0.5);
                break;
            case "75":
                ImgeWith = (int)(414 * 0.75);
                ImgeHeight = (int)(520 * 0.75);
                break;
                break;
            case "100":
                ImgeWith = 414;
                ImgeHeight = 798;
                break;
            case "150":
                ImgeWith = (int)(414 * 1.5);
                ImgeHeight = (int)(520 * 1.5);
                break;
            case "200":
                ImgeWith = 414 * 2;
                ImgeHeight = 520 * 2;
                break;
            case "300":
                ImgeWith = 414 * 3;
                ImgeHeight = 520 * 3;
                break;

        }
        showImage();
    }
}
